package edu.kit.csl.cratylus.extraction;

import java.util.List;
import java.util.Random;

import edu.kit.csl.cratylus.datatypes.Candidate;
import edu.kit.csl.cratylus.datatypes.Word;

/**
 * This merger randomly selects a element from the set of candidates and 
 * propagates it as representative for the set.
 */
public class RandomMerger implements Merger {
	
	private Random randomGenerator;
	
	/**
	 * Sole constructor. Initializes the random number generator.
	 */
	public RandomMerger() {
		randomGenerator = new Random();
	}

	/* (non-Javadoc)
	 * @see edu.kit.csl.cratylus.extraction.Merger#merge(java.util.List)
	 */
	@Override
	public Word merge(List<Candidate> candidates) {
		return candidates.get(randomGenerator.nextInt(candidates.size()))
				.getWord();
	}
}
